#include "GlosForhor.h"
#include <fstream>
#include <sstream>
#include <iostream>

GlosForhor::GlosForhor()
{
}


GlosForhor::~GlosForhor()
{
}

void GlosForhor::read_from_file(string filename)
{
	string row, str;
	ifstream fin;
	try
	{
		fin.open(filename);
		while (getline(fin, row))
		{
			istringstream iss(row);
			getline(iss, str, '=');
			if (str.compare("Glosa") == 0)
			{
				Glosa g;
				iss >> g;
				if (g.getGivenWord().compare("") != 0)
				{
					q.push_back(g);
				}
			}
		}
	}
	catch (exception e)
	{
		cout << e.what() << endl;
	}
}

void GlosForhor::run()
{
	while (!q.is_empty())
	{
		Glosa &g = q.pop_front();
		if (!g.ask())
			q.push_back(g);
	}
}
